import Taro, { Component } from '@tarojs/taro'
import { Swiper, SwiperItem, Image, View, Text,Input } from '@tarojs/components'
import '../../assets/common.scss'
import CommonJs from '../../utils/common'
import Hearder from './hearder'
import './card.scss'
import cat01 from '../../assets/kedouimg01/cat01.png'

export default class Index extends Component {
  constructor(props) {
    super(props)
    this.state = {
    	isload:1,
    	list:''
    }
  }
  config = {
    navigationBarTitleText:'我的会员卡'
  }
  open(url,type){
    CommonJs.openTo(url)
  }
  componentWillMount () {
    this.getdate();
    
  }
  componentDidShow () {

  }
 
  getdate(){
  	var url='/shop/papi/v1.9/members/card/bag';
  	var _this=this;
  	CommonJs.ajaxRequest(url,'','GET',function(res){
	     _this.setState({
	      list:res.data,
	      isload:1
	    })
	  },'wfw')
  }
  
  render () {
    const list = this.state.list
    return (
      <View className='page' style={this.state.isload==1?'display:block':'display:none'}>
      	<View className='card-page' style={list.length>0?'display:block':'display:none'}>
      			{list.map((item, index) => (
	      			<View className='card-list'>
	      					<View className='card-dl'>
	      						<View className='card-dt'>
	      							<Image className="cat-img" mode="widthFix" src={item.logo}></Image>
	      						</View>
	      						<View  className='card-dd'>
	      							<Text className='card-h3'>{item.levelVM.name}</Text>
	      							<Text className='card-price'>享受群内消费{item.levelVM.discount/100}折优惠</Text>
	      						</View>
	      					</View>
	      					<View className='card-info'>
	      						<Text className='card-fr'>有效期:长久有效</Text>
	      						<Text className='card-qun'>{item.groupName}社群及商城使用</Text>
	      					</View>
	      			</View>
	      		))}
      	</View>
      	<View className='card-page' style={list.length>0?'display:none':'display:block'}>
      		<View className='nodate'>暂无数据</View>
      	</View>
      </View>
    )
  }
}
